package com.zmn.oms.common.utils;

/**
 * 类描述：
 *
 * @author lhl
 * @date 2020/06/19 16:05
 */
public final class CharUtil {
    private static final String REGEX_MORE_THAN_4_CHARS = "[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]";

    /**
     * 过滤超过4个字节的UTF8编码（此范围编码包含emoji）
     * @param msg
     * @return
     */
    public static String filter(String msg) {
        if (msg == null || msg.length() == 0) {
            return msg;
        }
        return msg.replaceAll(REGEX_MORE_THAN_4_CHARS, "");
    }
}
